CC=g++
DIR=USS
OPATH=Obj
BIN=Bin

CLIBS=$(OPATH)/nsr.o $(OPATH)/ns-client*.o $(OPATH)/log.o
SLIBS=$(OPATH)/us-client-xdr.o $(OPATH)/log.o $(OPATH)/utf8.o $(OPATH)/config.o

SSOURCE=$(DIR)/US.cpp $(DIR)/USSserver.cpp $(DIR)/USS_svc.c 
SHEADERS=$(DIR)/US.h $(DIR)/USS.h

all: client server

xdr: $(DIR)/USS_xdr.c
	$(CC) $(CFLAGS) -c -o $(OPATH)/us-client-xdr.o $(DIR)/USS_xdr.c

client: $(DIR)/USSclient.h $(DIR)/USSclient.cpp $(DIR)/USS_clnt.c xdr
	$(CC) $(CFLAGS) -c -o $(OPATH)/us-client.o $(DIR)/USSclient.cpp
	$(CC) $(CFLAGS) -c -o $(OPATH)/us-client-rpc.o $(DIR)/USS_clnt.c

server: $(SLIBS) $(SSOURCE) $(SHEADERS)
	$(CC) $(CFLAGS) -o $(BIN)/us-server $(SLIBS) $(SSOURCE) -lmysqlclient -DRPC_SVC_FG
 
test: $(DIR)/test.cpp $(OPATH)/us-client*.o
	$(CC) $(CFLAGS) -o $(BIN)/us-test $(CLIBS) $(OPATH)/us-client*.o $(DIR)/test.cpp  

USS.h: USS.x
	rpcgen -C USS.x

